<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/templates/common/taglib.jsp"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
       <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>${title }</title>
    <link rel="stylesheet" href="${basePath}/static/bootstrap/css/bootstrap.css"/>
    <link href="${basePath}/static/css/basic.css" rel="stylesheet" type="text/css">
    <link href="${basePath}/static/css/login.css" rel="stylesheet" type="text/css">

    <link href="${basePath}/static/css/list.css" rel="stylesheet" type="text/css">
    <script  type="text/javascript" src="${basePath}/static/js/jquery.min.js"></script>
    <script  type="text/javascript" src="${basePath}/static/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="${basePath}/static/page/jqPaginator/jqPaginator.js"></script>
    <script  type="text/javascript" src="${basePath}/static/layer/layer.js"></script>
    <link href="${basePath}/static/layer/layer_defined.css" rel="stylesheet" type="text/css">
    
</head>
<body>
<!--头部-->
	<%@include file="/WEB-INF/templates/common/header.jsp"%>
	<!------导航条-->
	<%@include file="/WEB-INF/templates/common/navigation.jsp"%>

<!--内容部分-->
<div class="list_main lay_out" class="clearfix">
    <div class="list_DH">
        <%@include file="/WEB-INF/templates/common/indexPageAudit.jsp"%>
    </div>
    <div class="list_NR">
        <div class="loc">
            <h3 style="margin:0">病案返修查询</h3>
        </div>
        <div class="list_con_table">
        
        	 <div class="search_table">
                <ul class="clearfix" style="margin-bottom:0;">
				    <li class="Label_1" style="width:10%">识别码：&nbsp;</li>
				    <li class="Label_2"><input class="input_box" type="text"  name='mrId' id='mrId' value='' /></li>
				    <li class="Label_1" style="width:10%">姓名：&nbsp;</li>
				    <li class="Label_2"><input class="input_box" type="text"  name='name' id='name' value='' /></li>
				     <li class="Label_1" style="width:10%">出院日期：&nbsp;</li>
				    <li class="Label_2" style="width:30%">
                    	<input class="input_box" style="width:40%;" type="text"  name='startTime' id='outHospitalStartTime' value='' onFocus="WdatePicker()" />
                    	<span>&nbsp;-&nbsp;</span><input class="input_box" type="text" style="width:40%;"  name='endTime' id='outHospitalEndTime' value='' onFocus="WdatePicker()" />
                    </li>
				    <li class="Label_1" style="width:10%">身份证号：&nbsp;</li>
				    <li class="Label_2"><input class="input_box" type="text"  name='idCard' id='idCard' value='' /></li>
				    <li class="Label_1" style="width:10%">修改状态：&nbsp;</li>
				    <li class="Label_2">
				         <input type="radio" checked="checked" class="radio_cl" name='repaird' id='' value='1' />未修改&nbsp;&nbsp;
     <input type="radio" class="radio_cl" name='repaird'  value='2' />已修改
				    </li>
				    <li class="Label_1" style="width:10%">审核日期：&nbsp;</li>
				    <li class="Label_2" style="width:30%">
                    	<input class="input_box" style="width:40%;" type="text"  name='startTime' id='auditStartTime' value='' onFocus="WdatePicker()" />
                    	<span>&nbsp;-&nbsp;</span><input class="input_box" type="text" style="width:40%;"  name='endTime' id='auditEndTime' value='' onFocus="WdatePicker()" />
                    </li>
				    
				    <li class="Label_5">
				     <a onclick="searchQua()">查询</a>
				    <!--  <a onclick="exportMedFileReworkToExcel()">导出</a> -->
				    </li>
   				 </ul>
   			</div>
        
            <table class="Search_tableList" cellpadding="0" cellspacing="0">
                <tr>
             			<td class="tdLabel_4">姓名</td>
						<td class="tdLabel_4">识别码</td>
						<!-- <td class="tdLabel_4">身份证号</td> -->
						<td class="tdLabel_4">缺陷</td>
						<!-- <td class="tdLabel_4">审核时间</td> -->
						<td class="tdLabel_4">修改内容</td>
						<td class="tdLabel_4">操作</td>
                </tr>
                <tr id="loading" style="height:50px;display:none">
				   <td colspan="6" align="center" ><img src="${basePath}/static/layer/skin/default/loading-2.gif"></td>
				</tr>
                <tbody id="tbody">
                 <%-- <tr>
                	<td class="tdLabel_5">1-10525858</td>
                    <td class="tdLabel_5">6163543</td>
                    <td class="tdLabel_5">李靖环</td>
                    <td class="tdLabel_5">2017-05-26</td>
                    <td class="tdLabel_5">2017-05-26</td>
                    <td class="tdLabel_5">2017-05-26</td>
                    <td class="tdLabel_5">
                     <a class="btn_qx" style="padding:0px 5px 3px;background-size:100%;" onclick="scan(event)">首页</a>
                     <a class="btn_qx" style="padding:0px 5px 3px;background-size:100%;" onclick="edit(event)">修改</a>
                    </td>
                  </tr>  --%>
                </tbody>
            </table>
        </div>
        <div class="pageList">
            <ul class="pagination clearfix" id="page_plus"></ul>
            <div class="pagination">
                <div>总共：<b id="totalPage">0</b> 条信息    当前页是第 <b id="currentPage">0/0</b>　页</div>
            </div>		
        </div> 
        	
    </div>
</div>
<!------页脚部分--------->
<%@include file="/WEB-INF/templates/common/footer.jsp"%>

<!--JS部分-->
<script type="text/javascript">

	function searchQua(){
		queryQua(1,10);
	}

	function queryQua(pageNum,pageSize){
		
		var mrId=$("#mrId").val();
		var name=$("#name").val();
		var idCard=$("#idCard").val();
		var outHospitalStartTime=$("#outHospitalStartTime").val();
		var outHospitalEndTime=$("#outHospitalEndTime").val();
		var auditStartTime=$("#auditStartTime").val();
		var auditEndTime=$("#auditEndTime").val();
		var status = $("input[name='repaird']:checked").val();
		
		
		if((auditStartTime==null || auditStartTime=="") &&(mrId==null || mrId=="") &&(auditEndTime==null || auditEndTime=="") &&(outHospitalStartTime==null || outHospitalStartTime=="") && (outHospitalEndTime==null || outHospitalEndTime=='') && (name==null || name=='') && (idCard==null || idCard=='')){
			layer.alert("请输入查询条件!",{icon:7});
			return;
		}
		$.ajax({
			type:"post",
			url:"${basePath}/audit/medAuditRepairList",
			data:{idNumber:idCard,name:name,auditStartTime:auditStartTime,mrId:mrId,auditEndTime:auditEndTime,startTime:outHospitalStartTime,endTime:outHospitalEndTime,status:status,pageNo:pageNum,pageSize:pageSize},
			beforeSend:function(){
				$("#tbody").html("");
				$("#loading").show();
			},
			success:function(data){
			
			    $("#tbody").html("");
				$("#loading").hide();
				if(data.success){
					var modifyMapList = data.data.modifyMapList;
					var totalCount = data.data.totalCount;
					var html = "";
					if (modifyMapList.length > 0) {
						page(pageNum, totalCount,pageSize);
						for (var i = 0; i < modifyMapList.length; i++) {
							var modifyMap = modifyMapList[i];
							var medicalErrorLength = modifyMap.medicalErrorLength;
							var medicalErrorList = modifyMap.medicalErrorList;
							for (var j = 0; j < medicalErrorList.length; j++) {
								var  medicalError =medicalErrorList[j];
									if(j==0){
										html+="<tr>"+
										  "	<td class='tdLabel_5' rowspan='"+medicalErrorLength+"'>"+modifyMap.name+"</td>"+
										  "	<td class='tdLabel_5' rowspan='"+medicalErrorLength+"'>"+modifyMap.mrId+"</td>"+
										/*   " <td class='tdLabel_5' rowspan='"+medicalErrorLength+"'>"+modifyMap.idNumber+"</td>"+ */
										  "	<td class='tdLabel_5'>"+medicalError.name+"</td>"+
										 /*  " <td class='tdLabel_5'>"+medicalError.createTime+"</td>"+ */
										  " <td class='tdLabel_5'>"+(medicalError.reviseContent==undefined?'未修改':medicalError.reviseContent)+"</td>";
										 if(status==1){
											 html+= " <td class='tdLabel_5' rowspan='"+medicalErrorLength+"'><a target='_blank' firstGuid='"+modifyMap.firstGuid+"' onclick='scan(this)' class='int'>修改</a></td>";
										 }else{
											 html+=" <td class='tdLabel_5' rowspan='"+medicalErrorLength+"'><a target='_blank' firstGuid='"+modifyMap.firstGuid+"' onclick='scanSearch(this)' class='int'>查看</a></td>";
										 }
										  
										 html+=  "</tr>";
									}else{
										html+="<tr>"+
										  "	<td class='tdLabel_5'>"+medicalError.name+"</td>"+
										 /*  " <td class='tdLabel_5'>"+medicalError.createTime+"</td>"+ */
										   " <td class='tdLabel_5'>"+(medicalError.reviseContent==undefined?'未修改':medicalError.reviseContent)+"</td>"+
										  "</tr>";	
									}
							}
						}
						
						
						$("#tbody").html(html);
					}else{
						layer.alert('查询数据为空!', {icon: 5});
					    $("#tbody").html("");
	                    $("#currentPage").html("0/0");
						$("#totalPage").html("0");
						$("#page_plus").html("");	
					}
				}else{
					layer.alert(data.msg, {icon: 5});
					$("#tbody").html("");
					$("#currentPage").html("0/0");
					$("#totalPage").html("0");
					$("#page_plus").html("");
				}
			}
		})
		
	}
	
	 function page(currentPage,totalCounts,pageSize){
		   /*  var pageSize=1; */
            var visiblePages = 10;
	        var totalPages = Math.ceil(totalCounts/pageSize);
	        $('#page_plus').jqPaginator({
                totalCounts: totalCounts,
	            pageSize:pageSize,
	            visiblePages: visiblePages,
	            currentPage: currentPage,

	            first:'<li class="first"><a href="javascript:void(0);">首页</a></li>',
	            prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
	            next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
	            last: '<li class="last"><a href="javascript:void(0);">末页</a></li>',
	            page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
	            onPageChange: function (num,type) {
	          
	            	 if(type !='init'){
	                 
	            		 queryQua(num,pageSize);
	                 }
	            	
	                $("#totalPage").html(totalCounts);
	                $("#currentPage").html(num+"/"+totalPages);
	            }
	        });

	    }
	 
	 
	 /*  //首页按钮事件
	 function scan(event){
		 var target=$(event.target);
		 var guid=target.closest("tr").attr("data-guid");
		 location='http://localhost:28081/medical-manage/medrecord/medrecordHomePageManage?firstGuid='+guid;
	 }
	 //图片按钮事件
	 function pic(event){
		 var target=$(event.target);
		 var guid=target.closest("tr").attr("data-guid");
		 location='http://localhost:28081/medical-manage/medrecord/paginationMedrecordShow?firstGuid='+guid;
	 } */
	 //查看按钮事件
	 function scan(obj){
		 var target=$(obj);
		 var guid=target.attr("firstGuid");
		 window.open('${corePath}/medical_record/edit_home_page_index_form?visitGuid='+guid);
	 }
	 
	 function scanSearch(obj){
		 var target=$(obj);
		 var guid=target.attr("firstGuid");
		 //window.open('${corePath}/medical_record/searchHomePageIndexForm?visitGuid='+guid);
	 }
	 
	 
</script>
</body>
</html>